#ifndef _GEOMETRY_H_
#define _GEOMETRY_H_

#include <vector>
#include <iostream>
#include "defs.h"
#include "config.hpp"
#include "utility.hpp"
// #include "boundConds.h"

// class BoundConds;

class Geometry
{
public:
  VarArray<Coord_t, 2, 0> coord;
  // 面积只有 sx sy 大小需要计算
  VarArray<Area_t, 2, 0> si, sj;
  VarArray<real_t, 2, 0> vol;
  // 可对着402页的图进行参考，更形象
  // 两层 dummy cell
  int
      nci,  //  !< number of grid cells in i-direction
      ncj,  //  !< number of grid cells in j-direction
      imax, // !< max. dimensions in i-direction (0 <= i <= imax); imax = nci + 3
      jmax, // !< max. dimensions in j-direction (0 <= j <= jmax); jmax = ncj + 3
      il,   //  !< index of the 1st dummy cell in i-direction (right side); il = imax - 1
      jl,   //  !< index of the 1st dummy cell in j-direction (top side); jl = jmax - 1
      i2,   //  !< index of the last physical cell in i-direction; i2 = imax - 2 (physical cells start at index 2)
      j2;   // !< index of the last physical cell in j-direction; j2 = jmax - 2 (physical cells start at index 2)

  int nBound; // !< total number of boundary segments
  // 蠢是蠢了些，但容易理解  重复的工作量不大
  // 也可以像李新亮那样加上 if 判断语句  老师的不太可取，不易理解
  std::vector<BoundDescrp_t> BoundDescrp; // !< description of boundary segments

  Geometry() = default;
  ~Geometry() = default;
  /**
     * @brief Construct a new Geometry object
     * 
     * @param meshFname plot3d 文件格式 需要单独生成
     * @param boundFname generic 格式，需单独生成
     */
  Geometry(const Config &usrInput);
  Geometry(const Geometry &src) = delete;
  Geometry(Geometry &&src) = delete;
  Geometry &operator=(const Geometry &src) = delete;
  Geometry &operator=(Geometry &&src) = delete;

  void InitMetrics(void);

#ifdef TEST
  /**
     * @brief 网格检查
     * 
     * @param outMeshFname 
     */
  void PrintMeshASSCII(const std::string &outMeshFname);
  /**
   * @brief 打印转换后的边界信息
   * 
   * @param os 
   */
  void PrintBoundary(std::ostream &os) const;
#endif

private:
  void ReadBoundFile(const std::string &boundFname);
  void ReadMeshASSCII(const std::string &meshFname);
  void SetBoundDescrpt(void);
  CutExchg<real_t> cutExchgVol;
};

#endif